package diet

import (
	"github.com/bgmp/config"
	"github.com/bgmp/handler"
	"github.com/bgmp/middleware"
	"github.com/bgmp/model"
	"github.com/gin-gonic/gin"
	"net/http"
)

func (b Base) AddCustomizeFood(c *gin.Context, req *AddCustomizeFoodRequest) *AddCustomizeFoodResponse {
	if req.Weight <= 0 {
		handler.ReplyError(c, http.StatusBadRequest, "重量必须为正")
		return nil
	}

	req.UserId = middleware.GetUserId(c)
	err := req.Create(config.DB)
	if err != nil {
		handler.Errorf(c, err.Error())
		return nil
	}
	return &AddCustomizeFoodResponse{}
}

type AddCustomizeFoodRequest struct {
	model.CustomizeFood
}

type AddCustomizeFoodResponse struct {
}
